package com.icebergteam.warfacewidget.common;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;

import com.icebergteam.warfacewidget.core.connection.NetworkManager;
import com.icebergteam.warfacewidget.R;

public class NoInternetConnectionDialog {
	
	public static void showIsNoInternetConnection(final Activity activity) {
		showIsNoInternetConnection(activity, true);
	}
	
	public static void showIsNoInternetConnection(final Activity activity, final boolean finishActivity) {
		if(NetworkManager.isNetworkConnectectionEnabled(activity))
			return;
			
		new AlertDialog.Builder(activity)
	      .setIcon(android.R.drawable.ic_dialog_alert)
	      .setTitle(R.string.app_no_internet_connection)
	      .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
	      
	        public void onClick(DialogInterface dialog, int which){
	          // Exit the activity
	        	if(finishActivity)
	        		activity.finish();
	        }
	      })
	      .show();
	}
}
